<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:kiwi="http://www.kiwi-project.eu/jsf"
		    	xmlns:a4j="http://richfaces.org/a4j">

		<h1>RDF Metadata for #{currentContentItem.title}</h1>
		
		<p style="margin-top: 20px; margin-left: 10px; margin-right: 10px;" class="help">
		  In the following, you can browse and modify the RDF metadata (datatype and annotation properties)
		  associated with the page '#{currentContentItem.title}'. Note that changes only affect data stored
		  in the triple store and does not necessarily update the page. <em>For advanced users only!</em>
		</p>
		
		<h:form id="metadataForm">
			<rich:dataTable value="#{rdf.getCurrentResource().listLiterals()}" var="md" 
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
				rowKeyVar="row" id="metadataTable" styleClass="metadataTable">
				<f:facet name="header">
					<h:outputText value="Content Metadata"/>
				</f:facet>
		
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Property" />
					</f:facet>
					<h:outputText value="#{md.property.label}" />
				</rich:column>	
			
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Value" />
					</f:facet>
					<!-- TODO when editing, doesn't look perfect, 
					see http://chiralsoftware.com/richfaces-jboss-inplace-input/inplace-input-textarea.seam 
					for making it nicer...  -->
					<rich:inplaceInput value="#{md.value}" selectOnEdit="true">
						<a4j:support event="onviewactivated" reRender="metadataTable" />
					</rich:inplaceInput>
				</rich:column>	
			
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Language" />
					</f:facet>
					<h:outputText value="#{md.language}" id="propertyLanguage" />
				</rich:column>	
			
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Type" />
					</f:facet>
					<h:outputText value="#{md.type.label}" id="propertyType" />
				</rich:column>	
			
				<rich:column>
					<f:facet name="header">
						<h:outputText value="Action" />
					</f:facet>
					<h:commandButton action="#{rdf.removeRelation(md)}" value="Delete" disabled="false" />
				</rich:column>	
			
				<f:facet name="footer">
					<rich:columnGroup>
						<rich:column>New Metadata Property:</rich:column>
						<rich:column>
							<h:selectOneMenu 
								id="addlinkprop_selectproperty"
								value="#{rdf.currentResource.newLiteral.property}">
								<s:selectItems value="#{rdf.currentResource.possibleLiteralProperties}" var="prop"
									label="#{prop.label} (#{prop.prefix})" noSelectionLabel="Please select ..." />
								<f:converter xmlns:f="http://java.sun.com/jsf/core" converterId="jsfRdfaEntityConverter"/>
							</h:selectOneMenu>
							<h:commandButton action="#{rdf.addRelation()}" value="Add" />
						</rich:column>
						<rich:column colspan="3">
						</rich:column>
					</rich:columnGroup>
				</f:facet>
			</rich:dataTable>	
	    </h:form> 
</ui:composition>
